#region Header

// MS codename Velocity Distributed Cache Extensions.
// (c) 2009

#endregion

#region Usings

using System.Configuration;

#endregion

namespace Caching.Extensions.Core.Config
{
    /// <summary>
    /// Smart Cache configuration section handler
    /// </summary>
    /// <example>
    /// sample config section
    /// <code>
    ///&lt; smartCache &gt;
    ///  &lt; namedCaches &gt;
    ///    &lt; cache name="SmartCacheName1" backendCacheName="SecondLevelCacheName1" ttl="10 (seconds)" autoUpdate="true" /&gt;
    ///    &lt; cache name="SmartCacheName2" backendCacheName="SecondLevelCacheName2" ttl="10 (seconds)" autoUpdate="true" /&gt;
    ///  &lt;/ namedCaches &gt;
    ///&lt;/ smartCache &gt;
    /// </code>
    /// </example>
    public class SmartCacheConfigSection : ConfigurationSection
    {
        private const string NamedCachesSectionsName = "namedCaches";

        #region Properties

        private static readonly ConfigurationPropertyCollection s_properties = new ConfigurationPropertyCollection
                                                                                   {
                                                                                       new ConfigurationProperty(
                                                                                           NamedCachesSectionsName,
                                                                                           typeof (
                                                                                               SmartCacheConfigElementCollection
                                                                                               ),
                                                                                           null,
                                                                                           ConfigurationPropertyOptions.
                                                                                               IsRequired |
                                                                                           ConfigurationPropertyOptions.
                                                                                               IsDefaultCollection
                                                                                           )
                                                                                   };

        /// <summary>
        /// Gets the named caches.
        /// </summary>
        /// <value>The named caches.</value>
        public SmartCacheConfigElementCollection NamedCaches
        {
            get { return (SmartCacheConfigElementCollection) base[NamedCachesSectionsName]; }
        }

        /// <summary>
        /// Gets the collection of properties.
        /// </summary>
        /// <value></value>
        /// <returns>
        /// The <see cref="T:System.Configuration.ConfigurationPropertyCollection"/> of properties for the element.
        /// </returns>
        protected override ConfigurationPropertyCollection Properties
        {
            get { return s_properties; }
        }

        #endregion
    }
}